#+TITLE: Commandments
#+AUTHOR: Zelphir Kaltstahl
#+DATE: [2023-03-04 Sa]
#+LANGUAGE: English
#+TAGS: Scheme, The Seasoned Schemer
#+CREATOR: Emacs
#+EXCLUDE_TAGS: noexport, notexported
#+OPTIONS: ^:{} H:10 toc:2
#+STARTUP: content indent align inlineimages hideblocks entitiesplain nologdone nologreschedule nologredeadline nologrefile


* 11 - The Eleventh Commandment - Accumulation of results or maintaining state
:PROPERTIES:
:CUSTOM_ID: commandment-11
:END:

#+begin_quote
Use additional arguments when a function needs to know what other arguments to the function have been like so far.
#+end_quote

* 12 - The Twelfth Commandment - Avoiding of unchanging iteration arguments
:PROPERTIES:
:CUSTOM_ID: commandment-12
:END:

#+begin_quote
Use ~(letrec ...)~ to remove arguments that do not change for recursive application.
#+end_quote

However, in some Scheme dialects one can also use ~define~ in all or most contexts (definition contexts), so that one does not need to use ~letrec~.

* 13 - The Thirteenth Commandment - Usage of src_scheme[:exports code]{(letrec ...)} or named src_scheme[:exports code]{let} or inner src_scheme[:exports code]{(define ...)}
:PROPERTIES:
:CUSTOM_ID: commandment-13
:END:

#+begin_quote
Use src_scheme[:exports code]{(letrec ...)} to hide and to protect functions.
#+end_quote

* 14 - The Fourteenth Commandment - Usage of src_scheme[:exports code]{(call-with-current-continuation ...)}
:PROPERTIES:
:CUSTOM_ID: commandment-14
:END:

#+begin_quote
Use src_scheme[:exports code]{(letcc ...)} to return values abruptly and promptly.
#+end_quote

However, in Scheme dialects, it is called src_scheme[:exports code]{(call-with-current-continuation ...)} instead. One could write a macro transforming it into src_scheme[:exports code]{(letrec ...)} though.

* 15 - The Fifteenth Commandment - Usage of src_scheme[:exports code]{(let ...)}
:PROPERTIES:
:CUSTOM_ID: commandment-15
:END:

Use src_scheme[:exports code]{(let ...)} to name the values of repeated expressions in a function definition if they may be evaluated twice for one and the same use of the function.

* 16 – The Sixteenth Commandment – Usage of src_scheme[:exports code]{set!}
:PROPERTIES:
:CUSTOM_ID: commandment-16
:END:

Use src_scheme[:exports code]{(set! ...)} only with names defined in src_scheme[:exports code]{(let ...)}s.

(Or equivalent constructs, such as src_scheme[:exports code]{(define ...)} inside a procedure definition.)

* 17 – The Seventeenth Commandment – src_scheme[:exports code]{let} around src_scheme[:exports code]{lambda} for src_scheme[:exports code]{set!} usage
:PROPERTIES:
:CUSTOM_ID: commandment-17
:END:
 Use src_scheme[:exports code]{(set! x ...)} for src_scheme[:exports code]{(let ([x ...]) ...)} only, if there is at least one src_scheme[:exports code]{(lambda ...} between it and the src_scheme[:exports code]{(let ([x ...]) ...)}.

* 18 - The Eighteenth Commandment - Usage ods src_scheme[:exports code]{set!} for obsolete bindings only
:PROPERTIES:
:CUSTOM_ID: commandment-18
:END:
Use src_scheme[:exports code]{(set! x ...)} only when the value that src_scheme[:exports code]{x} refers to is no longer needed.
